# loading in SLICER packages
library("devtools")
Loading required package: usethis
install_github("jw156605/SLICER")
Skipping install of 'SLICER' from a github remote, the SHA1 (cb1be8ac) has not changed since last install.
Use `force = TRUE` to force installation
library(SLICER)
library(lle)
Loading required package: scatterplot3d
Loading required package: MASS
Attaching package: ‘MASS’
The following object is masked _by_ ‘.GlobalEnv’:
genotype
Loading required package: snowfall
Loading required package: snow
# finding the number of initial clusters for reconstructing the trajectory
k = select_k(top_genes_norm, kmin = 3)
finding neighbours
calculating weights
computing coordinates
finding neighbours
calculating weights
computing coordinates
finding neighbours
calculating weights
computing coordinates
finding neighbours
calculating weights
computing coordinates
finding neighbours
calculating weights
computing coordinates
finding neighbours
calculating weights
computing coordinates
finding neighbours
calculating weights
computing coordinates
finding neighbours
calculating weights
computing coordinates
finding neighbours
calculating weights
computing coordinates
finding neighbours
calculating weights
computing coordinates
# performing LLE a form of dimensionality reduction on the gene expression data
# m = 3 bc that is the number of dimensions used in the figures in the paper
traj_lle = lle(top_genes_norm, m=3, k)$Y
finding neighbours
calculating weights
computing coordinates
# build a knearest neighbor graph to find the distances betwen cells
traj_graph = conn_knn_graph(traj_lle, k)
# constructing the cell order and finding branches in the trajectory
ends = find_extreme_cells(traj_graph, traj_lle)

start = 1 # needs to be changed to a known cardiac fibroblast
cells_ordered = cell_order(traj_graph, start)
graph_process_distance(traj_graph,traj_lle,start)

branches = assign_branches(traj_graph,start, min_branch_len = 30)
distances = process_distance(traj_graph, 192)
scatterplot3d(traj_lle[,1],traj_lle[,3],traj_lle[,2], grid = FALSE)

library(rgl)
library(plotly)
Loading required package: ggplot2
Attaching package: ‘plotly’
The following object is masked from ‘package:ggplot2’:
last_plot
The following object is masked from ‘package:MASS’:
select
The following object is masked from ‘package:stats’:
filter
The following object is masked from ‘package:graphics’:
layout
plot3d(traj_lle[,1],traj_lle[,3],traj_lle[,2],type = "s", size = 1, lit = TRUE)
lle_df = data.frame(traj_lle )
lle_df$dist = as.double(t(distances))
fig <- plot_ly(lle_df, x = ~X1, y = ~X2, z = ~X3, marker = list(color = ~dist, colorscale = c('#FFE1A1', '#683531'), showscale = TRUE))
fig <- fig %>% add_markers()
fig <- fig %>% layout(scene = list(aspectmode = "cube"))
fig
plot(traj_lle,pch=16,col=branches)

LS0tCnRpdGxlOiAiUiBOb3RlYm9vayIKb3V0cHV0OiBodG1sX25vdGVib29rCi0tLQoKYGBge3J9CiMgbG9hZGluZyBpbiBTTElDRVIgcGFja2FnZXMKbGlicmFyeSgiZGV2dG9vbHMiKQppbnN0YWxsX2dpdGh1YigiancxNTY2MDUvU0xJQ0VSIikKbGlicmFyeShTTElDRVIpCmxpYnJhcnkobGxlKQpgYGAKCgpgYGB7cn0KIyBmaW5kaW5nIHRoZSBudW1iZXIgb2YgaW5pdGlhbCBjbHVzdGVycyBmb3IgcmVjb25zdHJ1Y3RpbmcgdGhlIHRyYWplY3RvcnkKayA9IHNlbGVjdF9rKHRvcF9nZW5lc19ub3JtLCBrbWluID0gMykKYGBgCmBgYHtyfQojIHBlcmZvcm1pbmcgTExFIGEgZm9ybSBvZiBkaW1lbnNpb25hbGl0eSByZWR1Y3Rpb24gb24gdGhlIGdlbmUgZXhwcmVzc2lvbiBkYXRhCiMgbSA9IDMgYmMgdGhhdCBpcyB0aGUgbnVtYmVyIG9mIGRpbWVuc2lvbnMgdXNlZCBpbiB0aGUgZmlndXJlcyBpbiB0aGUgcGFwZXIgCnRyYWpfbGxlID0gbGxlKHRvcF9nZW5lc19ub3JtLCBtPTMsIGspJFkKYGBgCgoKYGBge3J9CiMgYnVpbGQgYSBrbmVhcmVzdCBuZWlnaGJvciBncmFwaCB0byBmaW5kIHRoZSBkaXN0YW5jZXMgYmV0d2VuIGNlbGxzCnRyYWpfZ3JhcGggPSBjb25uX2tubl9ncmFwaCh0cmFqX2xsZSwgaykKYGBgCmBgYHtyfQojIGNvbnN0cnVjdGluZyB0aGUgY2VsbCBvcmRlciBhbmQgZmluZGluZyBicmFuY2hlcyBpbiB0aGUgdHJhamVjd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